using System;
using System.Globalization;
using System.Runtime.Serialization;

namespace UnitTesting.Fixturing
{
	[Serializable]
	public class ValueTypeMismatchedException : ValueProviderException
	{
		public ValueTypeMismatchedException()
		{
		}

		public ValueTypeMismatchedException(string message) : base(message)
		{
		}

		public ValueTypeMismatchedException(string message, Exception inner)
			: base(message, inner)
		{
		}

		internal ValueTypeMismatchedException(Type valueType) :
			base(string.Format(CultureInfo.InvariantCulture, "The value of the type '{0}' cannot be null", Ensure.IsNotNull(() => valueType)))
		{
			if (!valueType.IsValueType)
				throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The type '{0}' should be value type.", valueType));
		}

		internal ValueTypeMismatchedException(Type valueType, object value)
			: base(string.Format(CultureInfo.InvariantCulture, "The value '{1}' is not instance of the type '{0}'", Ensure.IsNotNull(() => valueType), value))
		{
		}

		protected ValueTypeMismatchedException(
			SerializationInfo info,
			StreamingContext context) : base(info, context)
		{
		}
	}
}